package com.iwuke.dance.wallet.mind_value;

import android.animation.ValueAnimator;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.iwuke.dance.R;
import com.iwuke.dance.activity.BaseActivity;
import com.iwuke.dance.util.Util;
import com.iwuke.dance.util.merchants_connect.NetworkEvent;
import com.iwuke.dance.wallet.mind_value.adapter.LevelAdapter;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;

/**
 * @author: 魏从响
 * @date: 2025/9/25
 * 心意值详情
 */
public class MindValueActivity extends BaseActivity implements View.OnClickListener {


    private ProgressBar progress_bar;
    private RecyclerView recycler_view;
    private ImageView img_right;
    private TextView tv_right;
    private ImageView img_left;

    @Subscribe(threadMode = ThreadMode.MainThread)
    public void onEvent(NetworkEvent networkEvent){
        BaseActivity.setConnect(MindValueActivity.this,networkEvent,null);

    }

    @Override
    protected int getView() {
        return R.layout.activity_mind_value;
    }

    @Override
    protected void init(View mView) {

        //返回
        img_left = findViewById(R.id.img_left);
        //跳转详细
        img_right = findViewById(R.id.img_right);
        //跳转详细
        tv_right = findViewById(R.id.tv_right);

        //进度条
        progress_bar = findViewById(R.id.progress_bar);


        //列表
        recycler_view = findViewById(R.id.recycler_view);

        //返回
        img_left.setOnClickListener(this);
        //跳转详细
        img_right.setOnClickListener(this);
        //跳转详细
        tv_right.setOnClickListener(this);
    }

    @Override
    protected void initData() {

        ValueAnimator animator = ValueAnimator.ofInt(0, 90);
        animator.setDuration(1000);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int progress = (int) animation.getAnimatedValue();
                progress_bar.setProgress(progress);
            }
        });
        animator.start();

        List<String> list = new ArrayList<>();
        for (int i=0;i<6;i++){
            list.add("");
        }
        GridLayoutManager gridLayoutManager = new GridLayoutManager(this,3);

        recycler_view.setLayoutManager(gridLayoutManager);
        LevelAdapter adapter = new LevelAdapter(this, R.layout.adapter_item_level, list);
        recycler_view.setAdapter(adapter);

    }

    @Override
    public void onClick(View v) {
        if (v.getId()==R.id.img_left){//返回
            finish();
        }else if (v.getId()==R.id.img_right||v.getId()==R.id.tv_right){//跳转详细
            Util.setIntent(MindValueActivity.this,MindValueDetailsActivity.class);
        }
    }
}
